package com.wans.easyuibackend.utils.validation;


import com.wans.easyuibackend.pojo.StaffInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@SuppressWarnings({"all"})
public class DataValidation {
    @Autowired
    private ChineseValidator chineseCharValidator;
    @Autowired
    private ContentValidation contentValidation;

    /**
     * @param staff 人员基本信息的实体对象
     * @return 数据格式是否正确
     */
    public boolean staffValidation(StaffInfo staff) {

        //数据校验
        boolean pureChinese = chineseCharValidator.isPureChinese(staff.getStaffName());
        boolean chineseSpelling = chineseCharValidator.isChineseSpelling(staff.getStaffName(), staff.getStaffNameSpelling());
        boolean genderVerify = contentValidation.staffGenderVerify(staff.getStaffGender());
        boolean identityTypeVerify = contentValidation.staffIdentityTypeVerify(staff.getStaffIdentityType());
        boolean identityVerify = contentValidation.staffIdentityVerify(staff.getStaffIdentityType(), staff.getStaffIdentity());
        boolean birthdayVerfy = staff.getStaffBirthday() != null;  //只要不为空即可，数据错误是无法来到数据校验的
        boolean phoneNumberVerify = contentValidation.staffPhoneNumberVerify(staff.getStaffPhoneNumber());
        boolean emailVerify = contentValidation.staffEmailVerify(staff.getStaffEmail());

        boolean identityDateVerify = contentValidation.staffIdentityDateVerify(staff.getStaffIdentityType(), staff.getStaffIdentity(), staff.getStaffBirthday());


        return pureChinese && chineseSpelling && genderVerify && identityVerify && identityVerify && birthdayVerfy && phoneNumberVerify && emailVerify && identityDateVerify;
    }

}
